package encode_decode;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * 长整型转字节编码器
 */
public class LongToByteEncoder extends MessageToByteEncoder<Long> {

    //编码
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, Long aLong, ByteBuf byteBuf) throws Exception {
        System.out.println("完成了长整型转字节编码：" + aLong);
        //完成长整型到byte的输出
        byteBuf.writeLong(aLong);
    }
}
